{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python385jvsc74a57bd04c36a90a135e4aa4256adc3692917ccc380701b533777f3da43dc8bc5264a29c",
   "display_name": "Python 3.8.5 64-bit ('base': conda)"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "source": [
    "# 第一次作业第2题\n",
    "作者：赵飞\n",
    "学号：202018019427078\n",
    "日期：2021-04-18"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "arr11: \n [[ 4  3  2]\n [ 1  0 -1]\n [-2 -3 -4]\n [-5 -6 -7]] \n\n所有元素的和： -18 \n\n每一列的和： [ -2  -6 -10] \n\n所有元素累计和： [  4   7   9  10  10   9   7   4   0  -5 -11 -18] \n\n每一列累计和：\n [[  4   3   2]\n [  5   3   1]\n [  3   0  -3]\n [ -2  -6 -10]] \n\n每一行累计积：\n [[   4   12   24]\n [   1    0    0]\n [  -2    6  -24]\n [  -5   30 -210]] \n\n所有元素最小值： -7 \n\n每一列最大值： [4 3 2] \n\n所有元素均值： -1.5 \n\n每一行均值： [ 3.  0. -3. -6.] \n\n所有元素中位数： -1.5 \n\n每一列中位数： [-0.5 -1.5 -2.5] \n\n所有元素方差： 11.916666666666666 \n\n每一行标准差： [0.81649658 0.81649658 0.81649658 0.81649658] \n\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "arr11 = 5 - np.arange(1, 13).reshape(4, 3)\n",
    "\n",
    "print(\"arr11: \\n\",arr11, '\\n')\n",
    "\n",
    "all_sum = np.sum(arr11)\n",
    "print(\"所有元素的和：\", all_sum, '\\n')\n",
    "\n",
    "col_sum = np.sum(arr11, axis=0)\n",
    "print(\"每一列的和：\", col_sum, '\\n')\n",
    "\n",
    "cum_sum = np.cumsum(arr11)\n",
    "print(\"所有元素累计和：\", cum_sum, '\\n')\n",
    "\n",
    "col_cum_sum = np.cumsum(arr11, axis=0)\n",
    "print(\"每一列累计和：\\n\", col_cum_sum, '\\n')\n",
    "\n",
    "row_cum_prod = np.cumprod(arr11, axis=1)\n",
    "print(\"每一行累计积：\\n\", row_cum_prod, '\\n')\n",
    "\n",
    "min_val = np.min(arr11);\n",
    "print(\"所有元素最小值：\", min_val, '\\n')\n",
    "\n",
    "col_max_val = np.max(arr11, axis=0)\n",
    "print(\"每一列最大值：\", col_max_val, '\\n')\n",
    "\n",
    "mean_val = np.mean(arr11)\n",
    "print(\"所有元素均值：\", mean_val, '\\n')\n",
    "\n",
    "row_mean_val = np.mean(arr11, axis=1)\n",
    "print(\"每一行均值：\", row_mean_val, '\\n')\n",
    "\n",
    "median_val = np.median(arr11)\n",
    "print(\"所有元素中位数：\", median_val, '\\n')\n",
    "\n",
    "col_median_val = np.median(arr11, axis=0)\n",
    "print(\"每一列中位数：\", col_median_val, '\\n')\n",
    "\n",
    "var_val = np.var(arr11)\n",
    "print(\"所有元素方差：\", var_val, '\\n')\n",
    "\n",
    "row_std_val = np.std(arr11, axis=1)\n",
    "print(\"每一行标准差：\", row_std_val, '\\n')"
   ]
  }
 ]
}